<%inherit file="base.html"/>
<%namespace name="main_ui" file="main_ui.html"/>
<%namespace name="sidebar_ui" file="sidebar_ui.html"/>
<%def name="head()">

<script>
function reactive(){
    $.post("/email/reactive",{},function(ev){
        alert(ev.msg);
    },"json");
}   
</script>
</%def>

<%def name="main()">
<div class="panel panel-default">
    <div class="panel-heading"> <i class="fa fa-user"></i> 用户信息
    </div>
    <div class="panel-body posts">
        <div class="pull-right">
            <a href="/user/update" class="btn btn-sm btn-info">修改基本资料</a>
        </div>
        <table class="table ">
                <thead>
                    <tr>
                        <th colspan="6"> 基本信息</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>用户姓名</td>
                        <td>${member.realname}</td>
                        <td>证件号码</td>
                        <td>${member.idcard}</td>
                        <td>用户登陆名</td>
                        <td>${member.member_name}</td>                 
                    </tr>
                    <tr>
                        <td>年龄</td>
                        <td>${member.age}</td>
                        <td>性别</td>
                        <td>${{0:u'女',1:u'男'}[member.sex]}</td>
                        <td>联系电话</td>
                        <td>${member.mobile}</td>
                    </tr>      
                    <tr>
                        <td>注册时间</td>
                        <td>${member.create_time}</td>
                        <td>最后更新</td>
                        <td>${member.update_time}</td> 
                        <td>地址</td>
                        <td>${member.address}</td>
                                           
                    </tr>   
                    <tr>
                        <td>email</td>
                        <td colspan="5">
                            ${member.email} 
                            % if member.email:
                            (${member.email_active == 1 and u'已绑定' or u'未绑定'})
                            % if member.email_active == 0:
                                <button type="button" class="opt-btn btn-default" onclick="javascript:reactive();" >发送激活邮件</button>
                             % endif
                             % endif
                        </td>                  
                    </tr>                                                                                         
            </tbody>
        </table>
        
        <table class="table table-striped ">
            <thead>
                <tr>
                    <th colspan="9"> 账号列表</th>
                </tr>
            </thead>
            <tbody>
            <tr class="active">
                <th>账号</th>
                <th>资费</th>
                <th>状态</th>
                <th>到期</th>
                <th>余额</th>
                <th>时长</th>
                <th>流量</th>
                <th>在线?</th>
                <th></th>
            </tr>            
            % for user in accounts:
            <tr ${status_colors[user.status]} ${online_colors(user.account_number)}>
                <td><a href="/account/detail?account_number=${user.account_number}">${user.account_number}</a></td>
                <td>${user.product_name}</td>
                <td>${{1:u"正常",2:u"停机",3:u"销户",4:u"到期",6:u"未激活"}[user.status]}</td>
                <td>${user.expire_date}</td>
                <td>${fen2yuan(user.balance)} 元</td>
                <td>${sec2hour(user.time_length)} 小时</td>
                <td>${kb2mb(user.flow_length)} M</td>
                <td>
                    ${is_online(user.account_number) and u'在线' or u'离线'}
                </td>
                 <td>
                     % if user.product_policy in (0,2,3,5):
                         <a class="opt-btn btn-default" href="/recharge?account_number=${user.account_number}">充值卡续费</a>
                     % elif user.product_policy in (1,4): 
                     <a class="opt-btn btn-default" href="/recharge?account_number=${user.account_number}">充值卡充值</a>
                     % endif
                     <a class="opt-btn btn-default" href="/password/update?account_number=${user.account_number}">修改密码</a>
                 </td>
            </tr>
            % endfor
            </tbody>
        </table>  
        <table class="table table-striped">
            <thead>
                <tr>
                    <th colspan="8"> 交易记录</th>
                </tr>
            </thead>
            <tbody>
            <tr class="active">
                <!-- <th>订单号</th> -->
                <th>资费</th>
                <th>账号</th>
                <th>订单费用</th>
                <th>实缴费用</th>
                <th>状态</th>
                <th>订单时间</th>
                <th width="20%">描述</th>
            </tr>            
            % for order in orders:
            <tr>
                <!-- <td>${order.order_id}</td> -->
                <td>${order.product_name}</td>
                <td>${order.account_number}</td>
                <td>${fen2yuan(order.order_fee)} 元</td>
                <td>${fen2yuan(order.actual_fee)} 元</td>
                <td>${{0:u"未支付",1:u"已支付",2:u"已取消"}[order.pay_status]}</td>
                <td>${order.create_time}</td>
                <td>${order.order_desc or ''}</td>
            </tr>
            % endfor
            </tbody>
        </table>
    </div>
</div>
</%def>

<%def name="sidebar()">
    ${sidebar_ui.login_box()}
    ${sidebar_ui.user_box()}
    ${sidebar_ui.service_box()}
    ${sidebar_ui.qrcode_box()}
</%def>